{{- $dialog := $.Stored.dialog -}}
{{- $multiple := $.Stored.multiple -}}
<div class="table-responsive">
    <table class="table no-border hover">
        <thead class="no-border auto-fixed" sort-current="{{$.Form `sort` `-id`}}">
            <tr>
                <th style="width:30px">
                    {{- if or (not $dialog) $multiple -}}
                    <div class="checkbox checkbox-primary no-margin-y">
                        <input type="checkbox" id="checkedAll">
                        <label for="checkedAll"></label>
                    </div>
                    {{- end -}}
                </th>
                {{- if not $dialog -}}
                <th style="width:60px" sort="-id"><strong>ID</strong></th>
                {{- end -}}
                <th style="width:55px"><strong>{{"图片"|$.T}}</strong></th>
                <th><strong>{{"原始名称"|$.T}}</strong></th>
                {{- if not $dialog -}}
                <th><strong>{{"保存位置"|$.T}}</strong></th>
                <th style="width:80px" sort="-type"><strong>{{"类型"|$.T}}</strong></th>
                <th style="width:60px" sort="-size"><strong>{{"大小"|$.T}}</strong></th>
                <th style="width:80px" sort="-width"><strong>{{"尺寸"|$.T}}</strong></th>
                {{- end -}}
                <th style="width:85px" sort="-created"><strong>{{"时间"|$.T}}</strong></th>
                {{- if not $dialog -}}
                <th style="width:60px" class="text-center"><strong>{{"操作"|$.T}}</strong></th>
                {{- end -}}
            </tr>
        </thead>
        <tbody class="no-border-y" id="tbody-content">
            {{range $k,$v := $.Stored.listData}}
            <tr>
                <td>
                    {{- if not $dialog -}}
                    <div class="checkbox checkbox-primary no-margin-y">
                        <input id="checkbox-{{$k}}" class="check-table" type="checkbox" name="id[]" value="{{$v.Id}}"{{if gt $v.UsedTimes 0}} disabled{{end}}>
                        <label for="checkbox-{{$k}}"></label>
                    </div>
                    {{- else if $multiple -}}
                    <div class="checkbox checkbox-primary no-margin-y">
                        <input id="checkbox-{{$k}}" class="check-table" type="checkbox" name="id[]" value="{{$v.Id}}" data-info='{{$v|JSONEncode}}'>
                        <label for="checkbox-{{$k}}"></label>
                    </div>
                    {{- else -}}
                    <div class="radio radio-primary no-margin-y">
                        <input id="radio-{{$k}}" class="check-table" type="radio" name="id" value="{{$v.Id}}" data-info='{{$v|JSONEncode}}' onclick="applySelected();">
                        <label for="radio-{{$k}}"></label>
                    </div>
                    {{- end -}}
                </td>
                {{- if not $dialog -}}
                <td>{{$v.Id}}</td>
                {{- end -}}
                <td class="no-padding">
                    <a href="{{$v.ViewUrl}}" target="_blank">
                        {{- if eq $v.Type `image` -}}
                        <img style="width:50px;height:50px" class="previewable" src="{{if $v.ViewUrl}}{{$v.ViewUrl}}{{else}}{{AssetsURL}}/images/nopreview.jpg{{end}}" onerror="this.onerror=null;this.src='{{AssetsURL}}/images/nopreview.jpg';" />
                        {{- else -}}
                        <img style="width:50px;height:50px" class="previewable" src="{{AssetsURL}}/images/nopreview.jpg" />
                        {{- end -}}
                    </a>
                </td>
                <td>
                    {{$v.Name}}
                    <div class="x-block">
                        <span class="label {{if gt $v.UsedTimes 0}}label-primary{{else}}label-default{{end}} label-xs">{{if gt $v.UsedTimes 0}}{{$.T `使用%d次` $v.UsedTimes}}{{else}}{{`未使用`|$.T}}{{end}}</span>
                        {{- if $dialog}}
                        <span class="label label-success label-xs">{{FormatBytes $v.Size 2 true}}</span>
                        {{if gt $v.Width 0}}<span class="label label-info label-xs">{{$v.Width}}&times;{{$v.Height}}</span>{{end}}
                        {{- end -}}
                    </div>
                </td>
                {{- if not $dialog -}}
                <td>{{$v.SavePath}}</td>
                <td>{{$v.Type}}</td>
                <td>{{FormatBytes $v.Size 2 true}}</td>
                <td>{{if gt $v.Width 0}}{{$v.Width}}&times;{{$v.Height}}{{else}}-{{end}}</td>
                {{- end -}}
                <td>{{(Date $v.Created).Format "2006-01-02 15:04:05"}}</td>
                {{- if not $dialog -}}
                <td class="text-center">
                    <a class="label label-danger" href="{{BackendURL}}/manager/file/delete/{{$v.Id}}" onclick="return confirm('{{`真的要删除吗？`|$.T}}');"><i class="fa fa-times"></i></a>
                </td>
                {{- end -}}
            </tr>
            {{end}}
        </tbody>
    </table>
</div>
{{- if $dialog -}}
{{($.Stored.pagination.SetNum 3).Render}}
{{- if eq ($.Form `partial`) `1` -}}
<script>
$(function(){
var uploadURL='{{$.Stored.uploadURL | Default (BackendUploadURL `default`)}}';
$('#input-file-upload').data('uploadPreviewer').url(uploadURL);
});
</script>
{{- end -}}
{{- else -}}
{{$.Stored.pagination.Render}}
{{- end -}}